package czk.jvm.lecture.classloader;

import java.sql.*;

public class MyTest27 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //System.out.println(System.getProperty("jdbc.drivers"));
        Class<?> aClass = Class.forName("com.mysql.jdbc.Driver");
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "1234");
        PreparedStatement preparedStatement = connection.prepareStatement("select * from user");
        ResultSet resultSet = preparedStatement.executeQuery();
        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();
        while (resultSet.next()){
            for (int i = 0; i < columnCount; i++) {
                String columnName = metaData.getColumnName(i);

                Object object = resultSet.getObject(i);
                System.out.println(columnName+"--------------"+object);
            }
        }
    }
}
